/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;
import javax.swing.ImageIcon;

/**
 *
 * @author Pioli
 */
public class Temporal extends javax.swing.JPanel {

    private Image bgImage;
    
    /**
     * Creates new form InicialPanel
     */
    public Temporal() {
        initComponents();
        
        //hace transparente al panel
        this.setOpaque(false);
        
        //le pone la imagen de fondo
        this.setBackgroundImage(this.createImage("/assets/main_page.jpg").getImage());
    }
    
    private ImageIcon createImage(String path) {
    URL imgURL = getClass().getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }
    private void setBackgroundImage(Image bgImage) {
        this.bgImage = bgImage;
    }
    @Override
    public void paint(Graphics g) {

        // Pintamos la imagen de fondo...
        if(bgImage != null) {
           g.drawImage(bgImage, 0, 0, null);
        }

        // Y pintamos el resto de cosas que pueda tener el panel
        super.paint(g);

    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setOpaque(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 682, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 641, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
